<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <base href="<%=basePath%>">

    <title>添加管理员</title>
    <link href="../css/bootstrap-cerulean.css" rel="stylesheet">
    <link href="../css/charisma-app.css" rel="stylesheet">
    <link href='../css/chosen.css' rel='stylesheet'>
    <link href='../css/uniform.default.css' rel='stylesheet'>
    <link href='../css/uploadify.css' rel='stylesheet'>
    <style type="text/css">
        body {
            padding-bottom: 40px;
        }

        .sidebar-nav {
            padding: 9px 0;
        }
    </style>
    <script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
    <script src="../js/common/public.js"></script>
    <script src="../js/base64.js"></script>
    <script src="../js/bootstrap-modal.js"></script>

    <script type="text/javascript">

        $(document).ready(function () {
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token = token.substring(0, token.length - 1);
            }
            $('#importDataList').attr('href', 'importDataList.html?token=' + token);


        });


        function upload() {
            $("#result").text("文件上传中...！请勿操作页面！ 0%");
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token = token.substring(0, token.length - 1);
            }
            var form = $('#uploadFile')[0];
            var data = new FormData(form);

            $.ajax({
                type: "POST",
                enctype: 'multipart/form-data',
                url: "http://localhost:1068/admin/upload?token=" + token,
                data: data,
                processData: false,
                contentType: false,
                cache: false,
                timeout: 600000,
                success: function (data) {
                    $("#result").text("上传成功，总数：" + data.data.totalCount + "  成功：" + data.data.importSuccessCount + "  失败：" + data.data.importFailCount);
                    $("#btnSubmit").prop("disabled", false);

                },
                error: function (e) {
                    $("#result").text(e.data);
                    $("#btnSubmit").prop("disabled", false);

                }
            });

        }




    </script>

</head>

<body>
<div class="container-fluid"
     style="padding-left:0px;padding-right:2px;">
    <div class="row-fluid">
        <div id="content" class="span10" style="width:100%;">
            <div class="row-fluid sortable">
                <div class="box span12">
                    <div class="box-header well">
                        <h2>
                            <i class="icon-edit"></i>导入数据信息
                        </h2>
                    </div>
                    <div class="box-content" style="text-align:center; padding-top:50px">
                        <form id="uploadFile" method="post" enctype="multipart/form-data">
                            <input type="hidden" name="operatetype" id="token" value="">
                            <fieldset>
                                <br>
                                <br>
                                <h1>导入数据信息</h1>
                                <br>
                                <br>
                                <br>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:14px">选择类型：</span>
                                        <select name="type" id="type" style="width:190px;">
                                            <option value="studentScoreInfo">操行信息</option>
                                            <option value="classScoreInfo">量化信息</option>
                                            <option value="studentInfo">学生信息</option>
                                            <option value="classInfo">班级信息</option>
                                        </select>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:14px">选择文件：</span>
                                        <input type="file" name="file">
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:18px"><a href="" id="importDataList">查看所有导入数据和导入出错数据</a></span>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <br>
                                <br>
                                <div class="control-group">
                                    <div class="controls">
                                        <span style="font-size:10px; color:red" id="result"></span>
                                    </div>
                                </div>
                                <br>
                                <br>
                                <div class="form-actions">
                                    <button type="button" onclick="upload()" class="btn btn-primary"
                                            style="width:100px;">提交
                                    </button>
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                    <button class="btn" onclick="javascript:history.go(-1);" type="reset"
                                            style="width:100px;">取消
                                    </button>
                                </div>
                            </fieldset>
                        </form>

                        <div style="padding-left:190px; padding-right:190px; text-align:left">
                            <h1>注意事项</h1>
                            <br>
                            <br>
                            <p><b>1.</b>&nbsp;目前导入文件支持Excel文件，支持office 2003版本 ，支持 office 2007版本。</p>
                            <br>
                            <p><b>2.</b>&nbsp;导入文件格式需要严格按照模板来，否则会出现未知错误。</p>
                            <br>
                            <p><b>3.</b>&nbsp;导入前系统会自动检验一下数据有没有错误，如果有错误会自动生成文件，点击导入页面的下载进行下载。</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
</html>